#include "Precompiled.hpp"


TypelessHandle::TypelessHandle() : myFactory(NULL), index(0), ID(0), valid(false)
{}

TypelessHandle::TypelessHandle(FactoryInterface* myFactory_, unsigned int index_, unsigned int ID_) : myFactory(myFactory_), index(index_), ID(ID_), valid(true)
{
}

TypelessHandle::~TypelessHandle()
{}

bool TypelessHandle::operator == (const TypelessHandle& rhs)
{
  return ((myFactory == rhs.myFactory) && (index == rhs.index) && (ID == rhs.ID));
}

void TypelessHandle::Delete()
{
  ASSERT(IsValid());
  myFactory->Delete(this);
}

bool TypelessHandle::IsValid() const
{
  valid = (valid && myFactory != NULL && myFactory->IsValid(this));
  return valid;
}

void* TypelessHandle::GetData()
{
  ASSERT(IsValid());
  return myFactory->GetData(this);
}

const void* TypelessHandle::GetData() const
{
  ASSERT(IsValid());
  return myFactory->GetData(this);
}

unsigned int TypelessHandle::GetIndex() const
{
  return index;
}

unsigned int TypelessHandle::GetID() const
{
  return ID;
}